package snapex.expense.mapper;

import static org.mybatis.dynamic.sql.SqlBuilder.*;
import static snapex.expense.mapper.StaffInfoDynamicSqlSupport.*;

import java.util.List;
import javax.annotation.Generated;
import org.apache.ibatis.annotations.DeleteProvider;
import org.apache.ibatis.annotations.InsertProvider;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Result;
import org.apache.ibatis.annotations.ResultMap;
import org.apache.ibatis.annotations.Results;
import org.apache.ibatis.annotations.SelectProvider;
import org.apache.ibatis.annotations.UpdateProvider;
import org.apache.ibatis.type.JdbcType;
import org.mybatis.dynamic.sql.SqlBuilder;
import org.mybatis.dynamic.sql.delete.DeleteDSL;
import org.mybatis.dynamic.sql.delete.MyBatis3DeleteModelAdapter;
import org.mybatis.dynamic.sql.delete.render.DeleteStatementProvider;
import org.mybatis.dynamic.sql.insert.render.InsertStatementProvider;
import org.mybatis.dynamic.sql.render.RenderingStrategy;
import org.mybatis.dynamic.sql.select.MyBatis3SelectModelAdapter;
import org.mybatis.dynamic.sql.select.QueryExpressionDSL;
import org.mybatis.dynamic.sql.select.SelectDSL;
import org.mybatis.dynamic.sql.select.render.SelectStatementProvider;
import org.mybatis.dynamic.sql.update.MyBatis3UpdateModelAdapter;
import org.mybatis.dynamic.sql.update.UpdateDSL;
import org.mybatis.dynamic.sql.update.render.UpdateStatementProvider;
import org.mybatis.dynamic.sql.util.SqlProviderAdapter;
import snapex.core.model.StaffInfo;

@Mapper
public interface HtcStaffInfoMapper {
    @Generated("org.mybatis.generator.api.MyBatisGenerator")
    @SelectProvider(type=SqlProviderAdapter.class, method="select")
    long count(SelectStatementProvider selectStatement);

    @Generated("org.mybatis.generator.api.MyBatisGenerator")
    @DeleteProvider(type=SqlProviderAdapter.class, method="delete")
    int delete(DeleteStatementProvider deleteStatement);

    @Generated("org.mybatis.generator.api.MyBatisGenerator")
    @InsertProvider(type=SqlProviderAdapter.class, method="insert")
    int insert(InsertStatementProvider<StaffInfo> insertStatement);

    @Generated("org.mybatis.generator.api.MyBatisGenerator")
    @SelectProvider(type=SqlProviderAdapter.class, method="select")
    @ResultMap("StaffInfoResult")
    StaffInfo selectOne(SelectStatementProvider selectStatement);

    @Generated("org.mybatis.generator.api.MyBatisGenerator")
    @SelectProvider(type=SqlProviderAdapter.class, method="select")
    @Results(id="StaffInfoResult", value = {
        @Result(column="stf_no", property="stfNo", jdbcType=JdbcType.VARCHAR, id=true),
        @Result(column="stf_namechn", property="stfNamechn", jdbcType=JdbcType.VARCHAR),
        @Result(column="stf_nameeng", property="stfNameeng", jdbcType=JdbcType.VARCHAR),
        @Result(column="stf_teamid", property="stfTeamid", jdbcType=JdbcType.VARCHAR),
        @Result(column="stf_lnaddr", property="stfLnaddr", jdbcType=JdbcType.VARCHAR)
    })
    List<StaffInfo> selectMany(SelectStatementProvider selectStatement);

    @Generated("org.mybatis.generator.api.MyBatisGenerator")
    @UpdateProvider(type=SqlProviderAdapter.class, method="update")
    int update(UpdateStatementProvider updateStatement);

    @Generated("org.mybatis.generator.api.MyBatisGenerator")
    default QueryExpressionDSL<MyBatis3SelectModelAdapter<Long>> countByExample() {
        return SelectDSL.selectWithMapper(this::count, SqlBuilder.count())
                .from(staffInfo);
    }

    @Generated("org.mybatis.generator.api.MyBatisGenerator")
    default DeleteDSL<MyBatis3DeleteModelAdapter<Integer>> deleteByExample() {
        return DeleteDSL.deleteFromWithMapper(this::delete, staffInfo);
    }

    @Generated("org.mybatis.generator.api.MyBatisGenerator")
    default int deleteByPrimaryKey(String stfNo_) {
        return DeleteDSL.deleteFromWithMapper(this::delete, staffInfo)
                .where(stfNo, isEqualTo(stfNo_))
                .build()
                .execute();
    }

    @Generated("org.mybatis.generator.api.MyBatisGenerator")
    default int insert(StaffInfo record) {
        return insert(SqlBuilder.insert(record)
                .into(staffInfo)
                .map(stfNo).toProperty("stfNo")
                .map(stfNamechn).toProperty("stfNamechn")
                .map(stfNameeng).toProperty("stfNameeng")
                .map(stfTeamid).toProperty("stfTeamid")
                .map(stfLnaddr).toProperty("stfLnaddr")
                .build()
                .render(RenderingStrategy.MYBATIS3));
    }

    @Generated("org.mybatis.generator.api.MyBatisGenerator")
    default int insertSelective(StaffInfo record) {
        return insert(SqlBuilder.insert(record)
                .into(staffInfo)
                .map(stfNo).toPropertyWhenPresent("stfNo", record::getStfNo)
                .map(stfNamechn).toPropertyWhenPresent("stfNamechn", record::getStfNamechn)
                .map(stfNameeng).toPropertyWhenPresent("stfNameeng", record::getStfNameeng)
                .map(stfTeamid).toPropertyWhenPresent("stfTeamid", record::getStfTeamid)
                .map(stfLnaddr).toPropertyWhenPresent("stfLnaddr", record::getStfLnaddr)
                .build()
                .render(RenderingStrategy.MYBATIS3));
    }

    @Generated("org.mybatis.generator.api.MyBatisGenerator")
    default QueryExpressionDSL<MyBatis3SelectModelAdapter<List<StaffInfo>>> selectByExample() {
        return SelectDSL.selectWithMapper(this::selectMany, stfNo, stfNamechn, stfNameeng, stfTeamid, stfLnaddr)
                .from(staffInfo);
    }

    @Generated("org.mybatis.generator.api.MyBatisGenerator")
    default QueryExpressionDSL<MyBatis3SelectModelAdapter<List<StaffInfo>>> selectDistinctByExample() {
        return SelectDSL.selectDistinctWithMapper(this::selectMany, stfNo, stfNamechn, stfNameeng, stfTeamid, stfLnaddr)
                .from(staffInfo);
    }

    @Generated("org.mybatis.generator.api.MyBatisGenerator")
    default StaffInfo selectByPrimaryKey(String stfNo_) {
        return SelectDSL.selectWithMapper(this::selectOne, stfNo, stfNamechn, stfNameeng, stfTeamid, stfLnaddr)
                .from(staffInfo)
                .where(stfNo, isEqualTo(stfNo_))
                .build()
                .execute();
    }

    @Generated("org.mybatis.generator.api.MyBatisGenerator")
    default UpdateDSL<MyBatis3UpdateModelAdapter<Integer>> updateByExample(StaffInfo record) {
        return UpdateDSL.updateWithMapper(this::update, staffInfo)
                .set(stfNo).equalTo(record::getStfNo)
                .set(stfNamechn).equalTo(record::getStfNamechn)
                .set(stfNameeng).equalTo(record::getStfNameeng)
                .set(stfTeamid).equalTo(record::getStfTeamid)
                .set(stfLnaddr).equalTo(record::getStfLnaddr);
    }

    @Generated("org.mybatis.generator.api.MyBatisGenerator")
    default UpdateDSL<MyBatis3UpdateModelAdapter<Integer>> updateByExampleSelective(StaffInfo record) {
        return UpdateDSL.updateWithMapper(this::update, staffInfo)
                .set(stfNo).equalToWhenPresent(record::getStfNo)
                .set(stfNamechn).equalToWhenPresent(record::getStfNamechn)
                .set(stfNameeng).equalToWhenPresent(record::getStfNameeng)
                .set(stfTeamid).equalToWhenPresent(record::getStfTeamid)
                .set(stfLnaddr).equalToWhenPresent(record::getStfLnaddr);
    }

    @Generated("org.mybatis.generator.api.MyBatisGenerator")
    default int updateByPrimaryKey(StaffInfo record) {
        return UpdateDSL.updateWithMapper(this::update, staffInfo)
                .set(stfNamechn).equalTo(record::getStfNamechn)
                .set(stfNameeng).equalTo(record::getStfNameeng)
                .set(stfTeamid).equalTo(record::getStfTeamid)
                .set(stfLnaddr).equalTo(record::getStfLnaddr)
                .where(stfNo, isEqualTo(record::getStfNo))
                .build()
                .execute();
    }

    @Generated("org.mybatis.generator.api.MyBatisGenerator")
    default int updateByPrimaryKeySelective(StaffInfo record) {
        return UpdateDSL.updateWithMapper(this::update, staffInfo)
                .set(stfNamechn).equalToWhenPresent(record::getStfNamechn)
                .set(stfNameeng).equalToWhenPresent(record::getStfNameeng)
                .set(stfTeamid).equalToWhenPresent(record::getStfTeamid)
                .set(stfLnaddr).equalToWhenPresent(record::getStfLnaddr)
                .where(stfNo, isEqualTo(record::getStfNo))
                .build()
                .execute();
    }
}